package cn.yangtianxia.basic.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;

@Component
public class EmailUtil {
@Autowired
private JavaMailSender javaMailSender;

private static JavaMailSender javaMailSender1;
@PostConstruct
public  void init(){
    javaMailSender1 = javaMailSender;
}
public static void sendMail(SimpleMailMessage simpleMailMessage){
    javaMailSender1.send(simpleMailMessage);
}


    public static SimpleMailMessage Email(String setFrom, String setTo,String setSubject,String setText) {
          SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(setFrom);
        message.setTo(setTo);
        message.setSubject(setSubject);
        message.setText(setText);
        return message;
    }



}
